###### 20 december 2013 kurgan sity russia Coloveov di ###########
#21#22
##############
scl = 7
##############
pos_y = 75 * scl
shag = scl * 2
def noten():
	global Fd,Gd,Ad,Bd,C,D,E,F,G,A,B,c,d,e,f,g,a,b
	Fd = pos_y - scl*2	
	Gd = pos_y - scl*1.5
	Ad = pos_y - scl*1
	Bd = pos_y - scl*0.5
	C = pos_y + scl*0
	D = pos_y + scl*0.5
	E = pos_y + scl*1
	F = pos_y + scl*1.5
	G = pos_y + scl*2
	A = pos_y + scl*2.5
	B = pos_y + scl*3
	c = pos_y + scl*3.5
	d = pos_y + scl*4
	e = pos_y + scl*4.5
	f = pos_y + scl*5
	g = pos_y + scl*5.5
	a = pos_y + scl*6
	b = pos_y + scl*6.5
noten()
f_o = open("soch1","r")
print "%!PS-Adobe-3.0 EPSF-3.0"
def readl():
	global r_l
	r_l = f_o.readline()
def text():
	global r_l
	print "/Times-Roman findfont"
	print str(pos_x) +" scalefont"
	print "setfont"
	print "newpath"
	print str(pos_x)+ " " + str(pos_y) + " " + " moveto"
	print "( "+r_l+ " ) show"
readl()
pos_x = 200
notta = f + scl*5
text()
def massr():
	global mass
	readl()
	mass = r_l.split()
cup = 750 + 10
fill = True
diez = False
dpal = False
dobup = False
vniz = False
trez = False
toch = False
bar = False
bemol = False
becar = False
fill = True
dobd = False
alter = False
liga = False
single = False
plusp = 0
def circle():
	print "newpath"
        print str(pos_x) + " " + str(notta) + " " + str(pos_y)+" 0 360 arc closepath"
	if fill == True:	
		print "0 0 0 setgray fill"
	print "0.5 setlinewidth"
        print "stroke"	
def line():
	print "newpath"
	print str(pos_x-scl)+" "+ str(pos_y) + " moveto"
	print str(pos_x+scl)+" "+ str(pos_y) + " lineto"
	if single == True:
		print str(pos_x-scl)+" "+ str(ln) + " moveto"
		print str(pos_x+scl)+" "+ str(ln) + " lineto"
		print "curveto" 	
	print "0.5 setlinewidth"
	print "stroke"
def nota():
########################################nota#################################################
		global pos_x,notta,dobd,fill,diez,dpal,dobup,cup,bemol,becar,toch,alter,plusp,single
		circle()
		if toch == True:
				circle()
		if dobd == True:
			if notta == Gd or notta == Ad:
				line()
			elif notta == Bd or notta == C:
				line()
		if dobup == True:
				line()
		if dpal == True:
			line()		
		else:
			line()
		if alter == True:
			text()			
		if single == True:
			if dpal == True:
				line()
			else:
				line()
		toch = False
		pos_x = pos_x + shag
		fill = True
		plusp = 0
#################################################nota###########################################
def per():
	if dpal == False:
				line()
	else:		
				line()
def persh():
		if dpal == False:
				line()
		else:
			pass
def takt():
			global pos_x			
			line()
			pos_x = pos_x + shag*1.7
def bar():
			line()
			pos_x = pos_x + shag*2	
def chords():
			text()
def obrab():
	global pos_x,notta,dobd,fill,i,one,onen,per,two,twon,dpal,dobup,plusp,vniz,trez,toch,bar,alt,chord,alter,single
	i = 0
	pos_x = scl*3
	for soch in mass:
		if soch == "||":
			bar()
			continue
		elif soch == "|":
			takt()
			continue
		#######chords
		elif soch[0] == '"':
			chord = soch
			sch = soch.replace('"','')
			chord = sch
			chords()
			continue
		else:
			pass
		for n in soch:
			if n[i] == "C":
					notta = C
					dobd = True		
			elif n[i] == "D":
					notta = D
			elif n[i] == "E":
					notta = E	
			elif n[i] == "F":	
				if vniz == True:
					notta = Fd
					dobd = True
				else:
					notta = F			
			elif n[i] == "G":
				if vniz == True:
					notta = Gd
					dobd = True
				else:
					notta = G
			elif n[i] == "A":
				if vniz == True:
					notta = Ad
					dobd = True
				else:
					notta = A
			elif n[i] == "B":
				if vniz == True:
					notta = Bd
					dobd = True
				else:
					notta = B
			elif n[i] == "c":
					notta = c
			elif n[i] == "d":
					notta = d
			elif n[i] == "e":
					notta = e
			elif n[i] == "f":
					notta = f
			elif n[i] == "g":
					notta = g
			elif n[i] == "a":
					notta = a
					dopup = True
			elif n[i] == "[":
					trez = True
					continue
			elif n[i] == "]":
					trez = False
					continue
			elif n[i] == "4":
					fill = False
					continue
			elif n[i] == "6":
					fill = False
					toch = True
					continue
			elif n[i] == "3":
					fill = True
					toch = True
					nota()
			elif n[i] == "2":	
					continue
			elif n[i] == "1":
					single = True			
			elif n[i] == "^":
					alter = True
					alt = "#"
					continue
			elif n[i] == "_":
					alter = True
					alt = "b"
					continue
			elif n[i] == "=":
					alter = True
					alt = "="
					continue
			elif n[i] == "(":
					one = pos_x
					onen = notta
					continue
			elif n[i] == ")":
					two = pos_x
					twon = notta
					per()
					continue
			elif n[i] == "}":
					two = pos_x
					twon = notta
					persh()
					continue
			elif n[i] == "~":
					alter = True
					alt = "~"
					continue
			elif n[i] == "u":
				dpal = False
				continue
			elif n[i] == "w":
				dpal = True
				continue
			elif n[i] == ",":
				vniz = True
				dopd = True
				continue
			elif n[i] == "'":
				vniz = False
				dopup = True
				continue
			elif n[i] == "+":
				plusp = plusp + scl/1.5
				continue
			elif n[i] == "-":
				plusp = plusp - scl/1.5
				continue
			elif n[i] == "z":
				pos_x = pos_x + shag/5
				alter = True
				notta = G
				alt = "z"
				continue
			elif n[i] == "p":
				pos_x = pos_x + shag
				continue
			else:
				pass
			if trez == True:
				pos_x = pos_x - shag
			else:
				pass
			nota()
			alter = False
			single = False
			dobd = False
			dobup = False
	i = i + 1
def stan():
	global pos_y
	i = 0
	while i < 5:
		line()
		pos_y = pos_y - scl
		i = i + 1
def obs():
	if len(r_l) > 0:
		stan()
		noten()
		obrab()
	else:
		pass
massr()
obs()
massr()
pos_y = 60 * scl
obs()
massr()
pos_y = 45 * scl
obs()
massr()
pos_y = 30 * scl
obs()
f_o.close()
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
